﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using FrameBLL;
using FrameEngine;
using wpfUI.UIs;

namespace wpfUI.ToolAndCommand
{
    public class NewFolderCommand : BaseCommand
    {
        private readonly IApplication _szApplication;
        /// <summary>
        /// 新建文件夹
        /// </summary>
        /// <param name="pApplication"></param>
        public NewFolderCommand(IApplication pApplication)
            : base(pApplication)
        {
            _szApplication = pApplication;
            ToolTip = "新建文件夹";
            Caption = "新建文件夹";
        }
        public override void UpdateEnableState()
        {
            if (!_szApplication.IsCanChangeTool)
            {
                IsEnabled = false;
                return;
            }

            IsEnabled = true;
        }

        public override void UpdateVisibleState()
        {
        }

        public override void OnClick()
        {
            base.OnClick();
            //执行命令
            //
            Application.IsCanChangeTool = false;
            var myDialog = new EditingDialog();
            myDialog.Title = "编辑";
            myDialog.Closed += Dialog_Closed;
            myDialog.Closing += myDialog_Closing;
            myDialog.Left = 50;
            myDialog.Top = 50;
            myDialog.Owner = _szApplication.MainWindow as Window;
            myDialog.Show();
        }
        void myDialog_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {

        }


        private void Dialog_Closed(object sender, EventArgs e)
        {
            Application.IsCanChangeTool = true;
        }
    }
}
